% Test the function makeppft filter.
%
% Yoel Shkolnisky, December 2010.
for precond=0:1
    for n=2:2:32
        A=rand(n,n,n);
        if precond
            tic;B=preconditionedAdjointPPFT3D(optimizedPPFT3D(A));t1=toc;
        else
            tic;B=optimizedAdjointPPFT3D(optimizedPPFT3D(A));t1=toc;
        end
        
        L=3*n-2; %n+2n-1-1
        filename=sprintf('filters\\H3Dfilter%dprecond%d.dat',n,precond);
        if exist(filename,'file')
            H=load3DHFilter(filename);
        else
            H=save3DHFilter(filename,n,precond);
        end

        Hhat=fftn(H.filter,[L L L]);

        tic;
        Ahat=fftn(A,[L L L]);
        Cc=ifftn(Ahat.*Hhat,[L L L]);
        Cc=Cc(n:2*n-1,n:2*n-1,n:2*n-1);
        t2=toc;

        reportTestResult(n,(norm(B(:)-Cc(:))./norm(B(:))),t1/t2);    
    end
end